-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cohttp-eio.Server: Don't blow up in callback
on client read timeout.
#1021
base: master
Are you sure you want to change the base?
Conversation
Why do we want to stop exceptions escaping? Typically they will just be logged by the user's I think it makes sense to drop connection-reset errors (or log them at debug level), since dropping connections is normal behaviour for a browser when you close a tab, but the others should be passed on I think. |
I would understand if you'd prefer to have it just below in Now regarding whether it belongs in Now what I would personally prefer would be for So my take is that 1/ it's mandatory to handle the exception in |
That would only happen if the user runs the server with Cohttp_eio.Server.run socket server
~on_error:(fun ex -> Logs.warn (fun f -> f "%a" Eio.Exn.pp ex)) |
You're right that it's because of the example's Regarding I think it's healthier for the library to do the most correct thing by default, which is handling interaction with the HTTP client including connection issues, or return a |
It shouldn't do. Even if you call Net.accept_fork manually, you still need to provide an Note that
When would users use I think having users log everything by default and adjusting it if the logs get filled with e.g. timeout spam would be reasonable. But in some cases seeing that timeouts keep happening would be useful. It's generally nicer for users if they can respond to problems by changing their code rather than having to file bug-reports. |
Sorry for the delay, I was successively off and swamped these past weeks. Agreed, I'm still a bit hesitant with the semantics of callback : it transparently handles all protocol level error and some transport level errors. If the client sends invalid headers, it will answer with bad_request, if the client closes the connection mid request, it will ignore it, etc. I'm not sure what the criteria is to determine what should be handled automatically and what should be forwarded to the user. I'm also always worried about the possibly escaping exception. Trying to properly handle them individually is very tedious, as it's hard to determine the set of possible exceptions, and I personally end up watching what exception kill my servers, add it to the list, rinse and repeat until hopefully they are all handled. The alternative is the infamous catching and ignoring all exceptions, but then you're also muting "no space left on device" or "file descriptor exhausted" exceptions, in which case you truly wanted the container to shut down and be replaced. Hence my idea that the library should handle all errors related to individual connections, and let through only exceptions that actually impact the process as a whole. My 2 cents; I can easily wrap the callbacks myself, feel free to close if you're unconvinced. |
The current situation (since #1023) is:
I don't mind too much either way, but the first is simpler. |
Yet another escaping exception. We can't catch the specific
Eio_unix.Unix_error (ETIMEDOUT, _, _)
since this is backend agnostic, so I'm stopping all backend exceptions. Which I dislike, suggestions welcome.Backtrace